<!DOCTYPE html>
<html lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/inc::header"/>
<body>
<table class="layui-table" id="grid" lay-filter="grid">
</table>
<script th:replace="/common/inc::incJs"></script>
<style type="text/css">
    .layui-table-cell {
        height: auto !important;
        white-space: normal;
    }
</style>
<script>
    var tableIns;

    $(function () {
        tableIns = createTable({
            url: 'list',
            cols: [[{field: 'id', title: '编号', width: 120},{field: 'title', title: '名称', width: 180},
                {field: 'photoUrl', title: '图标', width: 180,algin: "center", templet: "#imgtmp"},{
                    field: 'seq',
                    title: '排序',
                    width: 150
                }, {
                    title: '操作',
                    width: 200,
                    align: 'center',
                    toolbar: '#opbar'
                }
            ]],
            initSort: {
                field: 'seq',
                type: 'asc'
            }
        })
    });

    layui.table.on('tool(grid)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
        var data = obj.data; //获得当前行数据
        var layEvent = obj.event; //获得 lay-event 对应的值
        var tr = obj.tr; //获得当前行 tr 的DOM对象02\
        if (layEvent === 'del') { //删除
            delRecord("/backend/security/homeContent/del", obj)
        } else if (layEvent === 'change') { //删除
            changeStatus(data.id, data.status);
        } else if (layEvent === 'edit') { //编辑
            openDialog({
                url: "/backend/security/homeContent/detail?id=" + data.id,
                area: ["70%", "75%"],
                btn: ["保存", "取消"]
            });
        }
    });


    layui.form.on('submit(searchBtn)', function (data) {
        tableIns.reload({
            where: data.field
        });
        return false;
    });
</script>
<script type="text/html" id="imgtmp">
    <img src="{{d.photoUrl}}" style="width: 120px;height: 100px">
</script>
<script type="text/html" id="opbar">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
</script>
</body>
</html>
